// 引入mongoose 
const mongoose = require('mongoose');
// 引入数据库地址
const config = require('../config/index.js');

//链接数据库 mongodb
mongoose.connect(`${config.host}:${config.port}/${config.basedata}`,{})
const conn = mongoose.connection

conn.on('open', ()=>{
	console.log('数据库链接成功')
})
conn.on('error', ()=>{
	console.log('数据库链接失败',error)
})

module.exports = mongoose